#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dp[1010][1010];
char s[100010], t[100010], ans[1000010];

int main() {
	scanf("%s%s", s + 1, t + 1);
	int sl = strlen(s + 1), tl = strlen(t + 1);
	for(int i = 1; i <= sl; i++)
		for(int j = 1; j <= tl; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(s[i] == t[j])
				dp[i][j] = dp[i - 1][j - 1] + 1;
		}
	int i = sl, j = tl;
	while(dp[i][j] > 0) {
		if(s[i] == t[j]) {
			ans[dp[i][j]] = s[i];
			i--, j--;
		} else {
			if(dp[i][j] == dp[i - 1][j]) i--;
			else j--;
		}
	}
	printf("%s",ans+1);
	return 0;
}

